package com.wxl.config;


import com.wxl.util.SnowflakeIdWorker;
import com.wxl.util.ZkWorkerIdManager;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class SnowflakeConfig {

    @Bean
    public SnowflakeIdWorker snowflakeIdWorker(ZkWorkerIdManager zkWorkerIdManager) {
        // 从ZooKeeper获取已分配的Worker ID
        long workerId = zkWorkerIdManager.getWorkerId();
        System.out.println("当前Worker ID: " + workerId);
        return new SnowflakeIdWorker(workerId);
    }
}